package com.bosssoft.goods.config;

import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**
 * swagger 配置 一些用法：https://zhuanlan.zhihu.com/p/161947638
 * 一些注解： https://blog.csdn.net/qq_35425070/article/details/105347336
 *
 * @author Fang_Sir
 * @date 2021-04-12
 */
@Configuration
public class Swagger3Config {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.OAS_30)
                .apiInfo(goodsApi())
                .select()
                .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo goodsApi(){
        Contact contact = new Contact("方堃钟", "", "");
        return new ApiInfoBuilder()
                .contact(contact)
                .title("商品管理api")
                .description("电子商城-商品管理模块Api")
                .version("1.0")
                .build();
    }
}
